""" 
Copyright 2009 Texas A&M University
 
Licensed under the Apache License, Version 2.0 (the "License"); you may not use 
this file except in compliance with the License. You may obtain a copy of the 
License at

http://www.apache.org/licenses/LICENSE-2.0
  
Unless required by applicable law or agreed to in writing, software distributed 
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the License for the 
specific language governing permissions and limitations under the License.
"""

import zope.interface

class IMapperResults(zope.interface.Interface):
    """ """
    def getResults(self):
        """ """
    
    def finished(self):
        """ Return a boolean for whether or not the results are available """

class IMapper(zope.interface.Interface):
    """A transformer performs metadata transformation """
    
    def getFormats(self):
        """Return an iterable of tuples of transformations:
        [('marc21.bibliographic','marcxml.bibliographic'),
         ('marc21.holdings','marcxml.holdings')]"""
    
    def getOutputFormat(self, input_format):
        """Return the matching output for the given input format from this
        transformer"""
    
    def map(self, metadata):
        """Return the transformed metadata """

class IChainedMapper(IMapper):
    """ A chain of transformations. The factory for a class that implements
    this must also be capable of taking a named parameter, 'transformations'
    which is an iterable of tuples of source and destination formats similar
    to the one returned by the getFormats method. """
    
    def append(self, transformer):
        """ Append the next stage of the transformer """

class IMapperRegistry(zope.interface.Interface):
    def register(self, mapper):
        """ Register a mapper """
    
    def unregister(self, mapper):
        """ Unregsiter a mapper """
    
    def getMapper(self, source_format, destination_format):
        """ Find a transformer that goes from the source format to the
        destination format """
    
    def listMappers(self):
        """ Return a list of all registered mappers """

class IReducer(zope.interface.Interface):
    """ A reducer performs a reduction on metadata """
    
    def getFormats(self):
        """ Return an iterable of the formats that can be reduced by this
        reducer """
    
    def reduce(self, *metadata):
        """ Reduce multiple metadata object to one """
